package edu.lsnu.equipment_management_system.pojo.domain;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author lemon
 */
@Configuration
public class CustomCorsConfiguration implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        // 设置了可以被跨域访问的路径和可以被哪些主机跨域访问
        registry.addMapping("/**")
                .allowedOrigins("http://192.168.60.180:8020",
                        "http://192.168.60.180:8080",
                        "http://192.168.60.180:80",
                        "http://192.168.60.181:8020",
                        "http://192.168.60.159:8020",
                        "http://192.168.60.164:80",
                        "http://192.168.60.164:8080",
                        "http://localhost:8080",
                        "http://localhost:8020",
                        "http://127.0.0.1:8020",
                        "http://192.168.60.167:8020").allowCredentials(false)
                .allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS")
                .allowCredentials(false).maxAge(3600); // 单位：秒
    }
}
